<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>利用H5中cavas绘制图形</title>
</head>
<style>
#canvas{
    border: 1px solid black;
}
</style>

<body onload="draw('canvas');">
    <canvas id="canvas" width="400px" height="400px"></canvas>
</body>

<script type="text/javascript">
var canvas = document.getElementById("canvas");
var context = canvas.getContext("2d");
context.fillStyle="grey";
context.fillRect(0,0,400,400);
</script>
</html>